cmake_minimum_required(VERSION 3.0)

PROJECT(oraygpio)

option(ENABLE_SHARED_COM "enable shared com" ON)
option(ENABLE_FORCE_HWINFO "enable read hwinfo from file" ON)
option(CMAKE_VERBOSE_MAKEFILE "make verbose=1" OFF)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

add_definitions(-DMODTYPE="${MODTYPE}")
add_definitions(-DDEVICE="${HEADER}")

set(comfil
ctrl_misc_led.c
gpio-sysfs.cpp
io-infos.cpp
serial_name.cpp
)

add_library(oraygpio-common OBJECT ${comfil})
set_target_properties(oraygpio-common PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -fPIC")

set_target_properties(oraygpio-common PROPERTIES PUBLIC_HEADER "\
oraygpio.h;\
serial_name.h;\
")

install (TARGETS oraygpio-common
    PUBLIC_HEADER DESTINATION include/oraygpio
)

if(${PLATFORM} STREQUAL "hisi" )
add_subdirectory(hisi)
elseif(${PLATFORM} STREQUAL "jz" )
add_subdirectory(jz)
elseif(${PLATFORM} STREQUAL "rockchip" )
add_subdirectory(rockchip)
endif()

add_executable(oraygpio main.cpp)
target_link_libraries(oraygpio PUBLIC gpio)

install (TARGETS oraygpio
    RUNTIME DESTINATION sbin
)
